import request from '@/utils/request'

export const baseUrl = '/system/user-role'
export const baseApiName = '用户与角色相关'

export function create(data) {
    return request({
        url: `${baseUrl}`,
        method: 'post',
        data,
        apiName: `${baseApiName}创建`
    })
}

export function update(data) {
    return request({
        url: `${baseUrl}`,
        method: 'post',
        data,
        apiName: `${baseApiName}修改`
    })
}

export function findAll(params) {
    return request({
        url: `${baseUrl}`,
        method: 'get',
        params,
        apiName: `${baseApiName}列表`
    })
}

export function findPage(params) {
    return request({
        url: `${baseUrl}/page`,
        method: 'get',
        params,
        apiName: `${baseApiName}分页列表`
    })
}

export function findOneById(id) {
    return request({
        url: `${baseUrl}/${id}`,
        method: 'get',
        apiName: `${baseApiName}更具id查询`
    })
}


export function remove(id) {
    return request({
        url: `${baseUrl}/${id}`,
        method: 'delete',
        apiName: `${baseApiName}删除`
    })
}

export function removeIds(id) {
    return request({
        url: `${baseUrl}/del/batch`,
        method: 'post',
        apiName: `${baseApiName}id批量删除`
    })
}

export function userAddRole(data) {
    return request({
        url: `${baseUrl}/addRoleIdsByUserId`,
        method: 'post',
        data,
        apiName: `${baseApiName}创建`
    })
}

export function getRoleIdByUserId(params) {
    return request({
        url: `${baseUrl}/findRoleIdsByUserId`,
        method: 'get',
        params,
        apiName: `${baseApiName}`
    })
}

